package cn.tedu.file;

import java.io.*;

/**
 * @author :Colin
 * @version 创建时间: 2021/6/17 15:12
 */
/*本类用与测试字节输出流*/
public class TestOut {
    public static void main(String[] args) {
        method();
        //method2();

    }

    private static void method2() {
        OutputStream out=null;
        try{
            out= new BufferedOutputStream(new FileOutputStream("D:\\PUNK\\2.TXT"));
            out.write(123);
        }catch(Exception e){
            e.printStackTrace();

        }finally{
            try {
                out.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    private static void method() {
        OutputStream out=null;
        try{
            out=new FileOutputStream("D:\\PUNK\\1.TXT",true);
            //append表示输出内容是否追加，是Boolean，默认是false，不拼接

                out.write(97);


        }catch(Exception e){
            e.printStackTrace();
        }finally{
            try {
                out.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }



    }

}
